<%@ page import="com.space.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: 20064
  Date: 2020/2/12
  Time: 16:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>更改密码</title>
    <!-- 字体 -->
    <link href="https://fonts.font.im/css?family=Ruslan+Display" rel="stylesheet">

    <!-- 图标 -->
    <link rel="icon" type="image/png" sizes="144x144" href="../images/airplane.png"/>
    <link rel="apple-touch-icon" type="image/png" sizes="144x144" href="../images/airplane.png"/>
    <link href="../js/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">

    <!-- 其他 -->
    <link rel="stylesheet" href="../js/bootstrap-4.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/userStyle.css">

    <style type="text/css">
        body {
            background-image: url("../images/bg1.jpg");
        }
    </style>

</head>
<body>
<%
    String userAccount = "";
    String userPhone = "";
    User user = (User) session.getAttribute("userLogin");
    if (user != null) {
        userAccount = user.getUserAccount();
        userPhone = user.getUserPhone();
    }

%>
<div class="container">
    <div class="row">&nbsp;</div>
    <div class="row">
        <div class="header">
            <p>如果你不出去走走，你就会以为这就是世界。</p>
            <p>If you don't go out, you will think this is the world.</p>
        </div>
    </div>
    <div class="row">&nbsp;</div>
    <div class="row my-row">
        <div class="myForm rounded m-auto rounded">
            <form action="changeUserPwd.do" method="post">
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
                    </div>
                    <input type="text" class="form-control" placeholder="请输入账号"
                           required="required" name="userAccount" value="<%=userAccount%>">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><i class="fa fa-address-book fa-fw"></i></span>
                    </div>
                    <input type="text" class="form-control" placeholder="请输入手机号"
                           required="required" name="userPhone" value="<%=userPhone%>">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><i class="fa fa-key fa-fw"></i></span>
                    </div>
                    <input type="password" class="form-control" placeholder="请输入密码" required="required" name="userPwd">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><i class="fa fa-key fa-fw"></i></span>
                    </div>
                    <input type="password" class="form-control" placeholder="请确认密码" required="required"
                           name="confirmPwd">
                </div>
                <div class="fn text-right">
                    <a href="./userLogin.jsp">去登陆</a>
                </div>
                <div class="my-button">
                    <button class="btn btn-info" type="submit">修改密码</button>
                </div>
            </form>
        </div>
    </div>
</div>


</body>
<script type="text/javascript" src="../js/jquery-3.4.1/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../js/bootstrap-4.4.1-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $("form").submit(function () {
        if (!checkChangePwd() || !checkPwd()) {
            return false;
        }
    });

    function checkChangePwd() {
        var check = false;
        $.ajax({
            async: false,
            url: "checkChangePwd.do",
            type: "post",
            data: {userAccount: $("input[name='userAccount']").val(), userPhone: $("input[name='userPhone']").val()},
            dateType: "json",
            success: function (result) {
                check = result.check;
                if (!check) {
                    alert(result.msg);
                }
            }
        });
        return check;
    }

    function checkPwd() {
        var pwd1 = $("input[name='userPwd']").val();
        var pwd2 = $("input[name='confirmPwd']").val();
        if (pwd1 != pwd2) {
            alert("密码不一致！");
            return false;
        }
        return true;
    }


</script>
</html>
